#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

const int inf = INT_MAX / 2;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, c;
  cin >> n >> c;
  vector<int> p(n + 1), w(n + 1);
  for (int i = 1; i <= n; i ++) cin >> p[i] >> w[i];
  vector<int> sum(n + 1);
  partial_sum(w.begin(), w.end(), sum.begin());
  vector<vector<array<int, 2>>> dp(n + 1, vector<array<int, 2>>(n + 1, {inf, inf}));
  dp[c][c][0] = dp[c][c][1] = 0;
  for (int l = n; l >= 1; l --) {
    for (int r = l + 1; r <= n; r ++) {
      dp[l][r][0] = min({
        dp[l][r][0],
        dp[l + 1][r][0] + abs(p[l + 1] - p[l]) * (sum[n] - (sum[r] - sum[l])),
        dp[l + 1][r][1] + abs(p[r] - p[l]) * (sum[n] - (sum[r] - sum[l]))
      });
      dp[l][r][1] = min({
        dp[l][r][1],
        dp[l][r - 1][0] + abs(p[l] - p[r]) * (sum[n] - (sum[r - 1] - sum[l - 1])),
        dp[l][r - 1][1] + abs(p[r - 1] - p[r]) * (sum[n] - (sum[r - 1] - sum[l - 1]))
      });
    }
  }
  cout << min(dp[1][n][0], dp[1][n][1]) << endl;
}